package torres.item.effect;

import torres.entity.Entity;

/**
 * @author Torres
 * An Effect that decreases the health of the specified Entity.
 */
@SuppressWarnings("serial")
public class DamageEffect implements Effect {
	int damageValue;
	
	/**
	 * Creates a DamageEffect that hurts the player with the specified value.
	 * @param damageValue The damage to be done to the player.
	 */
	public DamageEffect(int damageValue) {
		
		this.setDamageValue(damageValue);
	}
	
	/**
	 * Apply this effect to the specified Entity.
	 * @param e The Entity that this Effect is affecting.
	 */
	@Override
	public void use(Entity e) {
		e.decCurrLife(this.getDamageValue());
	}
	
	/**
	 * Tests to see if this effect can successfully be applied to the specified Entity. 
	 * @param e The Entity on which to test if this affect can be applied.
	 * @return True if this effect can be applied to the Entity, false otherwise.
	 */
	public boolean canUse(Entity e) {
		return e.getCurrLife() >= this.getDamageValue();
	}
	
	/**
	 * Set the damage to be applied to the Entity.
	 * @param damageValue The damage to be applied to the Entity.
	 */
	private void setDamageValue(int damageValue) {
		
		this.damageValue = damageValue;
	}
	
	/**
	 * Get the damage to be applied to the Entity
	 * @return The damage to be applied to the Entity.
	 */
	private int getDamageValue() {
		
		return this.damageValue;
	}
}
